﻿using Caliburn.Micro;
using myapp.Databases.DAO;
using myapp.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace myapp.ViewModels
{
    /// <summary>
    /// List Possition View Model
    /// </summary>
    public class PossitonManagerViewModel : BaseViewModel
    {
        #region Attribute
        /// <summary>
        /// List of PossitionGroupViewModel
        /// </summary>
        private IObservableCollection<PossitionGroupViewModel> _items;

        #endregion

        #region Properties
        public IObservableCollection<PossitionGroupViewModel> Items
        {
            get
            {
                return _items;
            }
            set
            {
                if (!value.Equals(null))
                {
                    _items = value;
                    NotifyOfPropertyChange(() => Items);
                }
            }
        }
        #endregion

        #region Constructure
        public PossitonManagerViewModel()
        {           
            Title = "Possition Manager";
            _items = new BindableCollection<PossitionGroupViewModel>();
            List<PossitionGroupModel> lstGroupModel = PossitionDAO.ListPossitionGroup();
            foreach (PossitionGroupModel groupModel in lstGroupModel)
            {
                PossitionGroupViewModel groupViewModel = new PossitionGroupViewModel(groupModel);
                _items.Add(groupViewModel);
            }
        }
        #endregion

        #region Method

        #endregion
    }
}
